<style>
    .fl {
        float: left;
    }
    
    .fr {
        float: right;
    }
</style>
<div class="widget-head" style="margin-top:0;">
    <div class="widget-title">短信管理</div>
</div>
<div class="layui-container" style="width:100%;">
    <div class="layui-clear">
        <a class="layui-btn layui-btn-danger think-btn" data-type="del" data-url="/admin/sms/del">删除</a>
        <form method="GET" action="/admin/welcome/sms" class="fr layui-form" style="width:400px;">
            <div class="layui-input-inline fl" style="width:100px;">
                <php>$types = ['mobile'=>'手机号'];</php>
                <select name="searchtype">
                            <foreach name="types" item="vo" key="k">
                                <option value="{$k}" <if condition="$_GET['searchtype'] eq $k">selected</if>>{$vo}</option>
                            </foreach>
                        </select>
            </div>
            <div class="layui-input-inline fr" style="width:300px;">
                <button class="layui-btn fr" lay-submit>搜索</button>
                <input type="text" class="layui-input fr" style="width:230px;" name="keywords" placeholder="请输入关键词" value="{$_GET['keywords']}">
            </div>
            <php> $condition = $_GET['searchtype'] && $_GET['keywords'] ? "/searchtype/".$_GET['searchtype']."/keywords/".$_GET['keywords'] : '';</php>
            <script>
                var condition = '{$condition}';
            </script>
        </form>
    </div>
    <table id="list" lay-skin="line"></table>
    <!--  -->
    <script type="text/html" id="barDemo">
        <div class="action-btn">
            <a class="mini_del" href="javascript:;" data-url="/admin/sms/del/ids/{{d.id}}">删除</a>
        </div>
    </script>
    <script type="text/html" id="restatus">
        {{# if(d.status == 1){ }} <span class="xy-status">成功</span> {{# } else { }} <span class="xy-status red">失败</span> {{# } }}
    </script>

    <script type="text/html" id="rehasuse">
        {{# if(d.is_used == 1){ }} <span class="xy-status">已使用</span> {{# } else { }} <span class="xy-status red">未使用</span> {{# } }}
    </script>

</div>


<script>
    layui.use(['think'], function() {
        var think = layui.think;

        //第一个实例
        think.render({
            elem: '#list',
            // height: 500,
            url: '/admin/sms/getdata' + condition,
            toolbar: false,
            skin: 'line',
            cols: [
                [ //表头
                    {
                        type: 'checkbox'
                        // fixed: 'left'
                    }, {
                        field: 'id',
                        title: 'ID',
                        width: 80
                        // sort: true,
                        // fixed: 'left'
                    }, {
                        field: 'mobile',
                        title: '手机号',
                        sort: true
                    }, {
                        field: 'code',
                        title: '验证码',
                    }, {
                        field: 'status',
                        title: '发送状态',
                        toolbar: '#restatus'
                    }, {
                        field: 'is_used',
                        title: '是否被使用',
                        toolbar: '#rehasuse'
                    },{
                        field: 'create_time',
                        title: '发送时间',
                        width: 180,
                        templet: function(d) {
                            return think_time(d.create_time, 'Y-m-d H:i:s'); //think_time()是think.js里面的方法
                        }
                    }, {
                        title: '操作',
                        width: 150,
                        align: 'center',
                        toolbar: '#barDemo'
                    }
                ]
            ]
        }, '{$_GET["searchtype"]}', '{$_GET["keywords"]}');
    });
</script>